#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BUFSIZE 10

/*霍纳算法
 *
 */


long int horner(int coefficient[], int n, int x)
{
	int i;
	long int result = 0;

	for (i = 0; i <= n - 1; i ++)
	{
		result = result * x + coefficient[i];
	}
	return result;
}


int main()
{
	long int p;
	char arr[BUFSIZE] = {0};
	int BUF[BUFSIZE] = {0};
	
	fgets(arr,BUFSIZE-1,stdin);
	for(int i = 0;i < BUFSIZE && arr[i] != '\n'; i++)
	{
		BUF[i] = arr[i];
	}
	p = horner(BUF,strlen(arr),1); 
	printf("%ld\n",p);

	exit(0);
}
